```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面向对象编程三大特性 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d3748;
            border-radius: 0.5rem;
            padding: 1.5rem;
            position: relative;
        }
        .code-block pre {
            margin: 0;
            overflow-x: auto;
        }
        .code-block code {
            font-family: 'Courier New', Courier, monospace;
            color: #e2e8f0;
            font-size: 0.9rem;
        }
        .feature-card {
            transition: all 0.3s ease;
            border-radius: 0.75rem;
            overflow: hidden;
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0.1em;
            left: 0;
            width: 100%;
            height: 0.4em;
            background-color: rgba(118, 75, 162, 0.3);
            z-index: -1;
            border-radius: 0.2em;
        }
        .mermaid {
            background-color: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="serif text-4xl md:text-5xl font-bold mb-6">面向对象编程的<span class="highlight">三大特性</span></h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8 max-w-3xl mx-auto">探索封装、继承与多态如何构建现代软件设计的基石</p>
            <div class="flex justify-center space-x-4">
                <a href="#intro" class="px-6 py-3 bg-white text-indigo-700 font-medium rounded-full hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-book-open mr-2"></i>开始阅读
                </a>
                <a href="#visualization" class="px-6 py-3 border border-white text-white font-medium rounded-full hover:bg-white hover:bg-opacity-10 transition duration-300">
                    <i class="fas fa-project-diagram mr-2"></i>可视化图表
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Introduction -->
        <section id="intro" class="mb-16">
            <div class="text-center mb-12">
                <h2 class="serif text-3xl font-bold mb-4">模块化、可重用与易维护的代码艺术</h2>
                <p class="text-gray-600 max-w-3xl mx-auto">面向对象编程（OOP）的三大基本特征——<span class="font-medium text-indigo-600">封装</span>、<span class="font-medium text-purple-600">继承</span>和<span class="font-medium text-pink-600">多态</span>，构成了现代软件开发的核心范式。这些特征协同工作，帮助程序员创建结构清晰、易于扩展和维护的应用程序。</p>
            </div>

            <!-- Features Grid -->
            <div class="grid md:grid-cols-3 gap-8 mb-12">
                <!-- Feature 1: Encapsulation -->
                <div class="feature-card bg-white shadow-md">
                    <div class="p-6">
                        <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mb-4">
                            <i class="fas fa-box text-indigo-600 text-xl"></i>
                        </div>
                        <h3 class="serif text-xl font-bold mb-3 text-indigo-600">封装</h3>
                        <p class="text-gray-600 mb-4">将数据和操作数据的方法绑定在一起，隐藏内部实现细节</p>
                        <ul class="text-sm text-gray-500 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-400 mr-2 mt-1"></i>
                                <span>数据隐藏与访问控制</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-400 mr-2 mt-1"></i>
                                <span>通过公共接口与外部交互</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-400 mr-2 mt-1"></i>
                                <span>提升安全性与模块化</span>
                            </li>
                        </ul>
                    </div>
                </div>

                <!-- Feature 2: Inheritance -->
                <div class="feature-card bg-white shadow-md">
                    <div class="p-6">
                        <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mb-4">
                            <i class="fas fa-sitemap text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="serif text-xl font-bold mb-3 text-purple-600">继承</h3>
                        <p class="text-gray-600 mb-4">子类复用父类的属性和方法，建立类层次结构</p>
                        <ul class="text-sm text-gray-500 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-400 mr-2 mt-1"></i>
                                <span>代码重用与减少冗余</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-400 mr-2 mt-1"></i>
                                <span>扩展与特化父类功能</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-400 mr-2 mt-1"></i>
                                <span>建立清晰的类关系</span>
                            </li>
                        </ul>
                    </div>
                </div>

                <!-- Feature 3: Polymorphism -->
                <div class="feature-card bg-white shadow-md">
                    <div class="p-6">
                        <div class="w-12 h-12 bg-pink-100 rounded-full flex items-center justify-center mb-4">
                            <i class="fas fa-random text-pink-600 text-xl"></i>
                        </div>
                        <h3 class="serif text-xl font-bold mb-3 text-pink-600">多态</h3>
                        <p class="text-gray-600 mb-4">同一接口在不同对象中表现出不同行为</p>
                        <ul class="text-sm text-gray-500 space-y-2">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-pink-400 mr-2 mt-1"></i>
                                <span>方法重载与重写</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-pink-400 mr-2 mt-1"></i>
                                <span>运行时动态绑定</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-pink-400 mr-2 mt-1"></i>
                                <span>提高代码灵活性与扩展性</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Encapsulation Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-box text-indigo-600"></i>
                </div>
                <h2 class="serif text-2xl font-bold text-indigo-600">1. 封装（Encapsulation）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md p-6 mb-8">
                <p class="text-gray-700 mb-6">封装是将数据（属性）和操作数据的方法（函数或方法）绑定在一起，并隐藏对象的内部实现细节。通过封装，可以控制对对象数据的访问和修改，并通过公共接口与外部交互。</p>
                
                <h3 class="font-bold text-lg mb-3 text-gray-800">特点：</h3>
                <ul class="list-disc pl-5 mb-6 text-gray-700 space-y-2">
                    <li><span class="font-medium">数据隐藏</span>：将对象的内部状态（属性）隐藏在对象内部，只允许通过公开的接口（方法）进行访问和修改。</li>
                    <li><span class="font-medium">访问控制</span>：使用访问修饰符（如 <code class="bg-gray-100 px-1 rounded">private</code>、<code class="bg-gray-100 px-1 rounded">protected</code> 和 <code class="bg-gray-100 px-1 rounded">public</code>）来限制对数据的直接访问。</li>
                    <li><span class="font-medium">接口设计</span>：定义公共接口（方法）用于与外部进行交互，同时内部实现细节对外部隐藏。</li>
                </ul>

                <div class="code-block mb-6">
                    <div class="flex items-center text-gray-400 text-sm mb-2">
                        <i class="fab fa-java mr-2"></i>
                        <span>Java 示例代码</span>
                    </div>
                    <pre><code>public class Person {
    private String name;  // 私有属性

    // 公共构造函数
    public Person(String name) {
        this.name = name;
    }

    // 公共方法访问私有属性
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}</code></pre>
                </div>

                <div class="bg-blue-50 border-l-4 border-blue-400 p-4 rounded">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-lightbulb text-blue-500"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-blue-700">最佳实践：将属性设为私有（<code class="bg-blue-100 px-1 rounded">private</code>），并通过公共的getter和setter方法来控制访问。这样可以保护数据完整性，并在需要时添加验证逻辑。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Inheritance Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-sitemap text-purple-600"></i>
                </div>
                <h2 class="serif text-2xl font-bold text-purple-600">2. 继承（Inheritance）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md p-6 mb-8">
                <p class="text-gray-700 mb-6">继承是指一个类（子类）从另一个类（父类）继承属性和方法。继承允许子类复用父类的代码，同时可以扩展或重写父类的方法。</p>
                
                <h3 class="font-bold text-lg mb-3 text-gray-800">特点：</h3>
                <ul class="list-disc pl-5 mb-6 text-gray-700 space-y-2">
                    <li><span class="font-medium">代码重用</span>：子类继承父类的属性和方法，从而避免重复代码，提升代码复用性。</li>
                    <li><span class="font-medium">层次结构</span>：建立类之间的层次结构，使得子类具有父类的特性，并可以添加或修改功能。</li>
                    <li><span class="font-medium">方法重写</span>：子类可以重写（Override）父类的方法，以提供更具体的实现。</li>
                </ul>

                <div class="code-block mb-6">
                    <div class="flex items-center text-gray-400 text-sm mb-2">
                        <i class="fab fa-java mr-2"></i>
                        <span>Java 示例代码</span>
                    </div>
                    <pre><code>// 父类
public class Animal {
    public void eat() {
        System.out.println("Animal is eating");
    }
}

// 子类
public class Dog extends Animal {
    @Override
    public void eat() {
        System.out.println("Dog is eating");
    }
}</code></pre>
                </div>

                <div class="bg-purple-50 border-l-4 border-purple-400 p-4 rounded">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-exclamation-triangle text-purple-500"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-purple-700">注意：过度使用继承可能导致类层次结构过于复杂（"继承地狱"）。考虑优先使用组合而非继承，除非确实存在"is-a"关系。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Polymorphism Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 bg-pink-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-random text-pink-600"></i>
                </div>
                <h2 class="serif text-2xl font-bold text-pink-600">3. 多态（Polymorphism）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md p-6 mb-8">
                <p class="text-gray-700 mb-6">多态是指对象能够以多种形式出现的能力。它允许一个接口或方法在不同的对象中表现出不同的行为，主要通过方法重载和方法重写实现。</p>
                
                <h3 class="font-bold text-lg mb-3 text-gray-800">特点：</h3>
                <ul class="list-disc pl-5 mb-6 text-gray-700 space-y-2">
                    <li><span class="font-medium">方法重载</span>：在同一个类中可以定义多个方法名相同但参数不同的方法。</li>
                    <li><span class="font-medium">方法重写</span>：在子类中重写父类的方法，以实现特定的行为。</li>
                    <li><span class="font-medium">动态绑定</span>：方法调用在运行时确定具体实现，允许对象在运行时决定调用哪个方法。</li>
                </ul>

                <div class="code-block mb-6">
                    <div class="flex items-center text-gray-400 text-sm mb-2">
                        <i class="fab fa-java mr-2"></i>
                        <span>Java 示例代码</span>
                    </div>
                    <pre><code>// 父类
public class Animal {
    public void makeSound() {
        System.out.println("Animal makes a sound");
    }
}

// 子类
public class Dog extends Animal {
    @Override
    public void makeSound() {
        System.out.println("Dog barks");
    }
}

// 另一个子类
public class Cat extends Animal {
    @Override
    public void makeSound() {
        System.out.println("Cat meows");
    }
}

// 使用多态
public class TestPolymorphism {
    public static void main(String[] args) {
        Animal myAnimal = new Dog();  // 动态绑定
        myAnimal.makeSound();         // 输出：Dog barks

        myAnimal = new Cat();         // 动态绑定
        myAnimal.makeSound();         // 输出：Cat meows
    }
}</code></pre>
                </div>

                <div class="bg-pink-50 border-l-4 border-pink-400 p-4 rounded">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-info-circle text-pink-500"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-pink-700">多态是面向对象设计模式的基石，它允许我们编写更通用、更灵活的代码，能够处理未来可能添加的新类。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section id="visualization" class="mb-16">
            <h2 class="serif text-3xl font-bold mb-8 text-center">OOP三大特性关系图</h2>
            <div class="mermaid">
                classDiagram
                    class OOP {
                        <<核心特征>>
                        +封装
                        +继承
                        +多态
                    }
                    
                    class 封装 {
                        +数据隐藏
                        +访问控制
                        +接口设计
                    }
                    
                    class 继承 {
                        +代码重用
                        +层次结构
                        +方法重写
                    }
                    
                    class 多态 {
                        +方法重载
                        +方法重写
                        +动态绑定
                    }
                    
                    封装 --|> OOP
                    继承 --|> OOP
                    多态 --|> OOP
                    
                    note for 继承 "继承为多态提供了基础"
                    继承 ..> 多态
            </div>
        </section>

        <!-- Summary Section -->
        <section class="bg-indigo-50 rounded-xl p-8 mb-16">
            <h2 class="serif text-2xl font-bold mb-6 text-indigo-700">总结：三大特性的协同作用</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <p class="text-gray-700 mb-4">面向对象编程的三大特性不是孤立存在的，它们相互配合，共同构建了OOP的强大能力：</p>
                    <ul class="list-disc pl-5 text-gray-700 space-y-2">
                        <li><span class="font-medium">封装</span>提供了数据安全和模块化</li>
                        <li><span class="font-medium">继承</span>实现了代码重用和层次结构</li>
                        <li><span class="font-medium">多态</span>赋予了代码灵活性和扩展性</li>
                    </ul>
                </div>
                <div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <h3 class="font-bold text-gray-800 mb-2">真实世界的OOP</h3>
                        <p class="text-sm text-gray-600">在现代框架如Spring、Hibernate中，这三大特性无处不在。例如：</p>
                        <ul class="text-sm text-gray-600 mt-2 space-y-1">
                            <li><i class="fas fa-angle-right text-indigo-400 mr-1"></i> Spring的依赖注入利用多态</li>
                            <li><i class="fas fa-angle-right text-indigo-400 mr-1"></i> JPA实体继承实现数据模型复用</li>
                            <li><i class="fas fa-angle-right text-indigo-400 mr-1"></i> 封装保护了敏感业务逻辑</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-lg font-medium text-white">技术小馆</h3>
                    <p class="text-sm mt-1">探索编程艺术，品味技术精髓</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-indigo-300 hover:text-white transition duration-300 flex items-center">
                        <i class="fas fa-globe mr-2"></i>
                        <span>技术小馆地址</span>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-6 pt-6 text-sm text-gray-500 text-center">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
    </script>
</body>
</html>
```